
var vm = new Vue({
	el:'#rrapp',
	data:{
		q:{
            userName: null,
            mobile: null,
            sellerName: null
		},
        page: {currentPage: 0, pageSizes: [15, 30, 100], pageSize: 15, total: 0, ascending: [], descending: []},
        sellerEvaluateData:[],// 列表数据

    },
    mounted: function(){
        this.query();
    },
	methods: {
		search: function () {
            this.page.currentPage = 0;
            this.query();
        },

        query: function () {
            //查询参数
            var queryParam = this.q;

            // 分页参数
            queryParam.page = this.page.currentPage;
            queryParam.limit = this.page.pageSize;
            // loading
            /* const loading = this.$loading({
                 lock: true,
                 text: '数据加载中',
                 spinner: 'el-icon-loading'
             });*/
            //ajax 请求
            $.ajax({
                type: "POST",
                url: baseURL + "data/sellerevaluate/list",
                contentType: "application/json;charset=UTF-8",
                data: JSON.stringify(queryParam),
                success: function (r) {
                    //loading.close();
                    if (r.code == 0) {
                        vm.page.total = r.page.totalCount;
                        vm.sellerEvaluateData = r.page.list;
                    } else {
                        alert(r.msg);
                    }
                }
            });

        },

        // 页数变化
        handleSizeChange: function (val) {
            this.page.pageSize = val;
            this.query();
        },
        //当前页变化
        handleCurrentChange: function (val) {
            this.page.currentPage = val;
            this.query();
        },

        //删除 /屏蔽 评论
        updateEvaluate: function (type) {
            // 获取选中行数
            if(this.$refs.sellerEvaluateTable.selection.length == 0){
                this.$message({
                    message: '请先选择行 !',
                    type: 'warning'
                });
                return;
            }
            // 取出ids
            var ids= [];
            for(var i in this.$refs.sellerEvaluateTable.selection){
                ids.push(this.$refs.sellerEvaluateTable.selection[i].id);
            }
            var confirmMsg = "是否确认删除评论?";
            var confirmInfo = "删除评论提示";
            if (type === 1){ //屏蔽
                confirmMsg = "是否确认屏蔽评论?";
                confirmInfo = "屏蔽评论提示";
            }
            var self = this;

            this.$confirm(confirmMsg,confirmInfo, {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(function () {
                var loading = self.$loading({
                    lock: true,
                    text: '数据加载中',
                    spinner: 'el-icon-loading'
                });
                $.ajax({
                    type: "POST",
                    url: baseURL + "data/sellerevaluate/updateEvaluate",
                    contentType: "application/json",
                    data: JSON.stringify({"type": type, ids:ids}),
                    success: function(r){
                        loading.close();
                        if(r.code == 0){
                            alert('操作成功', function(index){
                                self.search();
                            });
                        }else{
                            alert(r.msg);
                        }
                    }
                });
            }).catch(function () {
                self.$message({
                    type: 'info',
                    message: '已取消操作'
                })
            });
        },
	}
});

